<?php

use Faker\Generator as Faker;
use App\Models\Notice;

$factory->define(\App\Models\Carousel::class, function (Faker $faker) {
    return [
        'title' => $faker->text(30),
        'type' => \App\Models\Carousel::TYPE_PRODUCT,
        'type_id' => rand(1, 50),
        'status' => randArray([0, 1]),
    ];
});


$factory->define(\App\Models\Notice::class, function (Faker $faker) {
    $type = randArray([Notice::TYPE_COUPON, Notice::TYPE_CATEGORY, Notice::TYPE_PRODUCT]);
    switch ($type) {
        default:
            $type_id = rand(1, 50);
            break;
        case Notice::TYPE_CATEGORY:
            $type_id = randArray(\App\Models\Category::query()
                ->doesntHave('children')->get()->pluck('id')->toArray());
            break;
        case Notice::TYPE_COUPON:
            $type_id = rand(1, 50);
            break;
    }
    return [
        'title' => $faker->text(30),
        'content' => $faker->text(200),
        'type' => $type,
        'type_id' => $type_id,
        'status' => randArray([0, 1]),
    ];
});